package com.ihealthway.all.interfaces.dwihealth.vo;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.PK;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.lang.Strings;

import javax.xml.bind.annotation.*;
import java.util.Date;

/**
 * Bean class for DW service plan item design
 * @author 凡梦星尘(elkan1788@gmail.com)
 */
@Table("interf_dw_cust_seritem")
@PK({"custNo", "custSerPlanNo"})
@XmlRootElement
@XmlType(propOrder = { "custSerPlanNo", "custConState" })
public class DWCustSerItem {

    @Column("cust_no")
    private String custNo;
    @Column("cust_serplan_no")
    private String custSerPlanNo;
    @Column("cust_con_state")
    private String custConState;

    @Column("create_time")
    private Date createTime;
    @Column("update_time")
    private Date updateTime;
    @Column("data_status")
    private String dataStatus;

    @XmlTransient
    public String getCustNo() {
        return custNo;
    }

    public void setCustNo(String custNo) {
        this.custNo = custNo;
    }

    @XmlElement(name = "CusServPlanNo")
    public String getCustSerPlanNo() {
        return custSerPlanNo;
    }

    public void setCustSerPlanNo(String custSerPlanNo) {
        this.custSerPlanNo = custSerPlanNo;
    }

    @XmlElement(name = "CustContState")
    public String getCustConState() {
        return custConState;
    }

    public void setCustConState(String custConState) {
        this.custConState = custConState;
    }
    @XmlTransient
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @XmlTransient
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @XmlTransient
    public String getDataStatus() {
        return dataStatus;
    }

    public void setDataStatus(String dataStatus) {
        this.dataStatus = dataStatus;
    }

    public ErrorInfoElement valid(String custNo) {
        ErrorInfoElement error = new ErrorInfoElement();
        error.setCustNo(custNo);
        error.setServPlanNo(this.custSerPlanNo);

        if (Strings.isBlank(custConState) || !Strings.equals(custConState, "1")
                || !Strings.equals(custConState, "0")) {
            error.setErrorInfo("CustConState的数据为空或值不符合");

        }

        this.custNo = custNo;
        this.dataStatus = "1";
        this.createTime = new Date();

        return error;
    }

    @Override
    public String toString() {
        return "DWCustSerItem{" +
                "custNo='" + custNo + '\'' +
                ", custSerPlanNo='" + custSerPlanNo + '\'' +
                ", custConState='" + custConState + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", dataStatus='" + dataStatus + '\'' +
                '}';
    }
}
